#include "stm32f10x.h"
#include "usart.h"
#include "car.h"
#include "stdio.h"

u32 TimingDelay = 0;
extern u8 parking_state;
extern u32 time[10];
extern u8 fee[10];
extern int car_id;
extern u8 fate;

//Main Body
int main(void)
{
	char text[20];
	SysTick_Config(SystemCoreClock/1000);
	STM3210B_LCD_Init();
  LCD_SetTextColor(White);
  LCD_SetBackColor(Blue2);
  LCD_Clear(Blue2);
	USART_CofigInit();
	all_Init();
	
	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
	while(1)
	{
		site_state_get();
		state_get();
		switch(parking_state){
			case state_default_showing:{
				sprintf(text," ID Code     Time    ");
				LCD_DisplayStringLine(Line2,text);
				sprintf(text,"   %d        %d:%d:%d       ",car_id+1,time[car_id]/3600,(time[car_id]%3600)/60,time[car_id]%60);
				LCD_DisplayStringLine(Line4,text);
				sprintf(text,"            Rates:%d",fate);
				LCD_DisplayStringLine(Line6,text);
			}break;
			case state_wait_tim_cmd:{
				sprintf(text," Please print ID code      ");
				LCD_DisplayStringLine(Line4,text);
				sprintf(text,"            Rates:%d",fate);
				LCD_DisplayStringLine(Line6,text);
			}break;
			case state_timing:{
				sprintf(text," ID Code     Time    ");
				LCD_DisplayStringLine(Line2,text);
				sprintf(text,"   %d        %d:%d:%d       ",car_id+1,time[car_id]/3600,(time[car_id]%3600)/60,time[car_id]%60);
				LCD_DisplayStringLine(Line4,text);
				sprintf(text,"            Rates:%d",fate);
				LCD_DisplayStringLine(Line6,text);
			}break;
			case state_wait_fee_cmd:{
				sprintf(text," Please print ID code       ");
				LCD_DisplayStringLine(Line4,text);
				sprintf(text,"            Rates:%d",fate);
				LCD_DisplayStringLine(Line6,text);
			}break;
			case state_fee_showing:{
				sprintf(text," ID Code      Fee    ");
				LCD_DisplayStringLine(Line2,text);
				sprintf(text,"    %d        %dYuan          ",car_id+1,fee[car_id]);
				LCD_DisplayStringLine(Line4,text);
				sprintf(text,"            Rates:%d",fate);
				LCD_DisplayStringLine(Line6,text);
			}break;
		}
	}
}

